package com.lori.netshop.service.imp;

import com.lori.netshop.dao.RedisDao;
import com.lori.netshop.dao.imp.RedisDaoimp;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import com.lori.netshop.service.RedisService;
import com.lori.netshop.util.NetshopResult;
@Service
public class RedisServiceimp implements RedisService {
	//注入redisdao
	@Autowired
	private RedisDao redisDaoimp;
	//注入资源文件的content在redis的key
	@Value("${INDEX_CONTENT_REDIS_KEY}")
	private String INDEX_CONTENT_REDIS_KEY;
	@Override
	public NetshopResult del(String key) {
		try {
			redisDaoimp.del(key);
		} catch (Exception e) {
			e.printStackTrace();
			return NetshopResult.build(500, "同步缓存失败", e.toString());
		}
		return NetshopResult.ok();
	}

	@Override
	public NetshopResult hdel(String field) {
		try {
			Long hdel = redisDaoimp.hdel(INDEX_CONTENT_REDIS_KEY, field);
		} catch (Exception e) {
			e.printStackTrace();
			return NetshopResult.build(500, "同步缓存失败",e.toString());
		}
		return NetshopResult.ok();
	}

}
